$(function() {
    $("._img").on("mousemove", function(e) {
        let $offsetX = $(".magnifier").offset().top;
        let $offsetY = $(".magnifier").offset().left;
        let $magnifierW = $(".magnifier").width();
        let $magnifierH = $(".magnifier").height();
        let $fousW = $(".fous").width();
        let $fousH = $(".fous").height();
        let $x = e.pageX - $offsetX - $fousW / 2 - 50;
        let $y = e.pageY - $offsetY - $fousH / 2 + 50;
        if ($x > $magnifierW - $fousW) {
            $x = $magnifierW - $fousW
        }
        if ($x < 0) {
            $x = 0
        }
        if ($y < 0) {
            $y = 0
        }
        if ($y > $magnifierH - $fousH) {
            $y = $magnifierH - $fousH
        }
        $(".fous")
            .css({
                left: $x,
                top: $y
            });
        $(".big-img")
            .show();
        $(".big-img img")
            .css({
                left: -$x * ($(".big-img img").width() / $fousW),
                top: -$y * ($(".big-img img").height() / $fousH)
            })
    })
    $("._img").on("mouseover", function() {
        $(".fous").show()

    })
    $("._img").on("mouseout", function() {
        $(".fous").hide();
        $(".big-img").hide();

    })

    // 规格数组对象数据
    let $businessArr = [{
        "images": {
            0: "https://p1.lefile.cn/product/adminweb/2021/07/21/aiMuDpZWB4DQAN53g5ugJYPAz-9709.w520.jpg",
            1: "https://p2.lefile.cn/product/adminweb/2021/04/21/Ljm3SOiSjZsHgpMEfHGQwPyvF-8042.w520.jpg",
            2: "https://p3.lefile.cn/product/adminweb/2021/04/21/Mn7sXzwQkOVc1ITnzhblVmIcm-4527.w520.jpg",
            3: "https://p1.lefile.cn/product/adminweb/2021/04/21/Vk7mN9TNZP3x8dfhUYT34Xuio-8648.w520.jpg"
        },
        "title": "ThinkPad X1 Titanium 英特尔Evo平台认证酷睿i5 至薄钛金笔记本",
        "h": "英特尔Evo平台认证酷睿 i5-1130G7/Windows 10 家庭中文版/16GB/512GB SSD/锐钜Xe显卡/13.5英寸2.2K 背光触控显示屏/手写笔",
        "price": 14999,
        "guige": {
            "spe1": "11代i5/16GB/512GB/2.2K屏/Wifi版",
            "spe2": "11代i7/16GB/512GB/2.2K屏/Wifi版",
            "spe3": "11代i7/16GB/1TB/2.2K屏/WiFi版",
            "spe4": "11代i7/16GB/512GB/2.2K屏/5G版",
            "spe5": "11代i7/16GB/1TB/2.2K屏/5G版"
        }
    }, {
        "images": {
            0: "https://p2.lefile.cn/product/adminweb/2021/07/21/67zqCi08rlSwNoDjBVVcL4ssr-9696.w520.jpg",
            1: "https://p2.lefile.cn/product/adminweb/2021/05/19/ktfEBXk0lXfAPHZn6S2TfUWQB-5462.w520.jpg",
            2: "https://p3.lefile.cn/product/adminweb/2021/04/21/OoXf2toUkmAQsxbYYB2imZx4v-4545.w520.jpg",
            3: "https://p1.lefile.cn/product/adminweb/2021/04/21/KITLxfeRdkDTppMVGYgUGvCjV-9703.w520.jpg"
        },
        "title": "ThinkPad X1 Carbon 2021 英特尔Evo平台认证酷睿i5 超轻旗舰本",
        "h": "英特尔Evo平台认证酷睿i5-1135G7/Windows 10 家庭中文版/16GB/512GB SSD/锐炬 Xe显卡/14英寸WUXGA 广视角技术 LED背光显示屏/LTE版/内置SIM卡(24个月流量)",
        "price": 9999,
        "guige": {
            "spe1": "11代i7/16G/512G/WUXGA屏",
            "spe2": "11代i5/16G/512G/WUXGA屏",
            "spe3": "11代i7/16G/1T/WUXGA屏",
            "spe4": "111代i7/32G/2T/4K屏",
            "spe5": "11代i7/16G/1T/4K屏"
        }

    }, {
        "images": {
            0: "https://p3.lefile.cn/product/adminweb/2021/07/21/Lqx7dbXqXd7MK2J15Xlwg0lIi-8583.w520.jpg",
            1: "https://p4.lefile.cn/product/adminweb/2021/04/22/sCrQ8nOQNhut6aWQPx8l7T6uS-5046.w520.jpg",
            2: "https://p2.lefile.cn/product/adminweb/2021/04/22/SuPKuLHziv3H5ogmCY4DegS1a-1353.w520.jpg",
            3: "https://p4.lefile.cn/product/adminweb/2021/04/22/IcG1LdjBVtT9UfhLPuwL2jHEG-6240.w520.jpg"
        },
        "title": "ThinkPad X13 2021 英特尔Evo平台认证酷睿i5 全互联便携商旅本",
        "h": "英特尔Evo平台认证酷睿i5-1135G7/Windows 10 家庭中文版/16GB/512GB SSD/锐炬Xe显卡/13.3英寸2.5K LED背光显示屏/LTE版/内置SIM卡（24个月流量）",
        "price": 8299,
        "guige": {
            "spe1": "11代i5/16GB/512GB/2.5K屏",
            "spe2": "11代i7/16GB/512GB/2.5K屏",
            "spe3": "11代i7/16GB/1TB/2.5K屏",
            "spe4": "11代i7/32GB/2TB/2.5K屏",
            "spe5": "11代i5/16GB/512GB/WUXGA"
        }

    }, {
        "images": {
            0: "https://p4.lefile.cn/product/adminweb/2021/07/21/4SwbEsHLzOU5ef9j8FGR9FfpJ-0283.w520.jpg",
            1: "https://p2.lefile.cn/product/adminweb/2020/09/22/0zYMqxzJZJb2VcOxE45NGoysU-8520.w520.jpg",
            2: "https://p4.lefile.cn/product/adminweb/2020/09/22/M36hiyTOCrKkp4aynoBb3PvX1-2845.w520.jpg",
            3: "https://p4.lefile.cn/product/adminweb/2020/09/22/53TzOyBbRt9nDMTqhmC1gnFht-6370.w520.jpg"
        },
        title: "【王源推荐】全新ThinkBook 14 锐龙版 锐智系创造本 4HCD",
        "h": "AMD锐龙5 5600U移动处理器/Windows 10 家庭中文版/16GB/512GB SSD/核心显卡（Radeon Graphics）/14英寸广视角技术 FHD LED背光显示屏（100% sRGB）/电源键指纹识别/银灰色",
        price: 4299,
        guige: {
            spe1: "【新品】 锐龙5六核十二线程/16G/51...",
            spe2: "【新品】 锐龙7八核十六线程/16G/51...",
            spe3: "【新品】锐龙5六核十二线程/16G/51...",
            spe4: "【新品】锐龙7八核十六线程/16G/51...",
            spe5: "【新品】锐龙7八核十六线程/16G/51..."
        }
    }, {
        "images": {
            0: "https://p1.lefile.cn/product/adminweb/2021/07/21/DxUJ1wz0KT2pde1pRrt3xB5XK-2550.w520.jpg",
            1: "https://p4.lefile.cn/product/adminweb/2020/09/22/Gu222udtRuxgJLWJDKG6zfSKN-8895.w520.jpg",
            2: "https://p4.lefile.cn/product/adminweb/2020/09/22/WTX8TCTxDm1M9LONrdlgwHZc3-3206.w520.jpg",
            3: "https://p2.lefile.cn/product/adminweb/2020/09/22/labrcskcTOHPrQYvPs1yvoSFH-7749.w520.jpg"
        },
        title: "【王源推荐】ThinkBook 15p 英特尔酷睿i5 视觉系创造本 01CD",
        "h": "第十代智能英特尔酷睿i5-10300H/Windows 10 家庭中文版/8G+8G/512GB SSD/NVIDIA GeForce GTX 1650/15.6英寸FHD LED背光显示屏（100% sRGB高色域/TUV低蓝光认证）指纹解锁一键开机/银灰色",
        price: 5999,
        guige: {
            spe1: "十代i5标压/16G/512G/GTX1650/FHD",
            spe2: "11代i5/16G/512G/MX450/FHD",
            spe3: "11代i5/16G/512G/锐炬Xe/FHD",
            spe4: "11代i7/16G/512G/MX450/FHD",
            spe5: "十代i7标压/16G/512G/GTX1650Ti/4K"
        }
    }];
    let $Id = window.location.href.substr(window.location.href.indexOf("?") + 1);

    $(".small1").attr("src", $businessArr[$Id].images[0])
    $(".small2").attr("src", $businessArr[$Id].images[1])
    $(".small3").attr("src", $businessArr[$Id].images[2])
    $(".small4").attr("src", $businessArr[$Id].images[3])
    $(".title").html($businessArr[$Id].title);
    $(".dec").html($businessArr[$Id].h);
    $(".price-show").html($businessArr[$Id].price);
    $(".gui1").html($businessArr[$Id].guige.spe1);
    $(".gui2").html($businessArr[$Id].guige.spe2);
    $(".gui3").html($businessArr[$Id].guige.spe3);
    $(".gui4").html($businessArr[$Id].guige.spe4);
    $(".gui5").html($businessArr[$Id].guige.spe5);
    $("._img img").attr("src", $businessArr[$Id].images[0])
    $(".big-img img").attr("src", $businessArr[$Id].images[0])

    $(".list li").on("click", function() {
        $(this).addClass("checked")
            .siblings().removeClass("checked");
        let $index = $(this).index();
        $("._img img").attr("src", $businessArr[$Id].images[$index])
        $(".big-img img").attr("src", $businessArr[$Id].images[$index])
    })

    $(".spec-big ").on("click", function() {
        $(this).addClass("active").siblings().removeClass("active")
    })



    let $txt = $(".txt")
    $(".reduce").on("click", function() {
        let $v = $txt.val();
        if ($v <= 1) {
            $txt.val(1);
        } else {
            $txt.val(parseInt($v) - 1);
        }
    })

    $(".add").on("click", function() {
        let $v = $txt.val();
        $txt.val(parseInt($v) + 1);
    })

    $(".sou").click(function() {
        location.href = "./index.html"
    })
})